package com.muy.redis.view.window.redis.bean;

import com.google.common.base.Objects;

import java.io.Serializable;

/**
 * @Author jiyanghuang
 * @Date 2023/9/15 20:36
 */
public class MrRedisDb implements Serializable {

    /**
     * db index, from 0
     */
    private Integer index;

    /**
     * key的个数
     */
    private Long keyCount;

    private String connectionId;

    @Override
    public String toString() {
        return String.format("DB%s (%s)", index, keyCount);
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        MrRedisDb dbInfo = (MrRedisDb) o;
        return Objects.equal(index, dbInfo.index) && Objects.equal(connectionId, dbInfo.connectionId);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(index, connectionId);
    }

    public Integer getIndex() {
        return index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public Long getKeyCount() {
        return keyCount;
    }

    public void setKeyCount(Long keyCount) {
        this.keyCount = keyCount;
    }

    public String getConnectionId() {
        return connectionId;
    }

    public void setConnectionId(String connectionId) {
        this.connectionId = connectionId;
    }
}
